package com.gm.wholesale.view.tabview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.gm.commonlib.views.BadgeView;
import com.gm.wholesale.R;

public class TabView extends LinearLayout {
   private TextView titleTextView;
   private View ntView;
   private BadgeView badgeView;
    public TabView(Context context) {
        super(context);
        initView(context);
    }

    public TabView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    private void initView(Context context){
        LayoutInflater.from(context).inflate(R.layout.view_tab_item, this);
        titleTextView=findViewById(R.id.tabItemView);
        ntView=findViewById(R.id.ntView);
        badgeView=new BadgeView(context,ntView);
        badgeView.setBadgePosition(BadgeView.POSITION_TOP_RIGHT);
       // badgeView.setBadgeMargin(10,-1);
    }

    public void showView(String title){
        titleTextView.setText(title);
    }
    public void showNt(long size){
        if (size<=0){
            badgeView.hide();
        }
        else {
            badgeView.setText(size+"");
            badgeView.show();
        }
    }

    public void showCheck(){
        titleTextView.setBackgroundResource(R.drawable.tab_item_check_shap);
        titleTextView.setTextColor(getResources().getColor(R.color.white));
    }

    public void showUnCheck(){
        titleTextView.setBackgroundColor(getResources().getColor(R.color.color_F2F3F6));
        titleTextView.setTextColor(getResources().getColor(R.color.black));
    }
}
